let form = layui.form;
console.log(location.search);
let id = location.search.substr().substring(4);
// let id = new URLSearchParams(location.search).get("id");
console.log(id);
$.ajax({
  type: "GET",
  url: "/admin/users/" + id,
  success: function (res) {
    if (res.status === 0) {
      form.val("a", res.data);
    } else {
      layer.msg(res.message);
    }
  },
});

// 更新用户信息
$("form").on("submit", function (e) {
  e.preventDefault();
  let data = $(this).serialize();
  console.log(data);
  $.ajax({
    type: "PUT",
    url: "/admin/users",
    data: data,
    success: function (res) {
      layer.msg(res.message);
    },
  });
});
